﻿using Music.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace Music.VariableTemplate
{
    public class VariableTiles: DataTemplateSelector
    {
        public DataTemplate BigFeaturedTemplate { get; set; }
        public DataTemplate FeaturedTemplate { get; set; }
        public DataTemplate NormalTemplate { get; set; }
        protected override Windows.UI.Xaml.DataTemplate SelectTemplateCore(object item, Windows.UI.Xaml.DependencyObject container)
        {
            FrameworkElement element = container as FrameworkElement;
            if (item != null && element != null)
            {
                if (item.GetType() == typeof(HubPageDataItem))
                {
                    if ((item as HubPageDataItem).UniqueId.StartsWith("BigFeatured"))
                        return BigFeaturedTemplate;
                    if ((item as HubPageDataItem).UniqueId.StartsWith("Featured"))
                        return FeaturedTemplate;
                    if ((item as HubPageDataItem).UniqueId.StartsWith("Normal"))
                        return NormalTemplate;
                }

                else if (item.GetType() == typeof(CategoryDataItem))
                {
                    if ((item as CategoryDataItem).UniqueId.StartsWith("Normal"))
                        return NormalTemplate;
                }
            }
            return base.SelectTemplateCore(item, container);
        }
    }
}
